package org.social.controller;

import java.util.Date;
import java.util.List;

import org.bean.PlayerInfo;
import org.social.db.bean.PlayerMap;
import org.social.db.cache.PlayerMapCache;

import com.dal.gm_api.api.IPlayer;
import com.dal.gm_api.pojo.GMPlayerInfoDTO;
import com.google.common.collect.Lists;
import com.xiaoleilu.hutool.bean.BeanUtil;

/**
 * 玩家信息
 *
 * @author win7
 */
public class PlayerServer implements IPlayer {



    @Override
    public List<GMPlayerInfoDTO> getPlayerInfo(List<Integer> pidList) {
        List<GMPlayerInfoDTO> result = Lists.newArrayList();
        pidList.forEach(pid -> {
            PlayerMap playerMap = PlayerMapCache.me().getByPid(pid);
            if (playerMap == null) {
				return;
			}
            
            result.add(buildPlayerInfoDTO(playerMap.getPlayerMapProxy().toPlayerInfo()));
        });
        return result;
    }

    @Override
    public boolean operatePlayer(int type, List<Integer> pidList, Date startDate, Date endDate) {
        return false;
    }

    @Override
    public String getDataByPlayer(int pid, String dataType) {

        return null;
    }

    private GMPlayerInfoDTO buildPlayerInfoDTO(PlayerInfo playerInfo) {
        GMPlayerInfoDTO dto = new GMPlayerInfoDTO();
        BeanUtil.copyProperties(playerInfo, dto);
        return dto;
    }






}